package one;

/**
 * 简单工厂类
 * 测试运算工厂类
 * 通过一个Operation运算类构造一个工厂，创造出不同的运算类
 * 共同属性Number1和Number2，和最终的结果Result
 * 抽象创造出Operation
 * 因为不同的计算方式AddOperation..，继承与运算类Operation
 * 最终创建工厂类OperationFactory根据不同的计算方式，实例化不同的对象
 */
public class TestOperationFactory {
    public static void main(String[] args) throws Exception {
        Operation operation = OperationFactory.createOperation("+");
        operation.setNumber1(1);
        operation.setNumber2(2);
        System.out.println("创造加法最终结果:"+operation.getResult());
        //最终结果:3.0
        Operation operation1 = OperationFactory.createOperation("*");
        operation1.setNumber1(1);
        operation1.setNumber2(2);
        System.out.println("创造乘法最终结果:"+operation1.getResult());

    }
}
